package com.microservices.cloud.controller;

import com.microservices.cloud.entities.CommonResult;
import com.microservices.cloud.service.StorageService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.plaf.synth.SynthOptionPaneUI;
import java.util.UUID;

@RestController
@Slf4j
public class StorageController {


    @Resource
    private StorageService storageService;


    @RequestMapping(value = "/storage/decrease",method = RequestMethod.POST)
    public CommonResult decrease(@RequestParam("productId") Long productId, @RequestParam("count") Integer count) {
        storageService.updateStorage(productId, count);
        return new CommonResult(200, "库存扣减成功");
    }


    public static void main(String[] args) {
        for (int i = 0; i < 14; i++) {
            System.out.println(UUID.randomUUID().toString());
        }
    }

}
